package com.ct.gd.passport.view.weather;
import android.os.AsyncTask;

import com.ct.gd.passport.view.weather.util.WeatherFacade;

/**
 * 天气查询任务类
 * @author twinkle
 *
 */
public class UpdateWeatherTask extends AsyncTask<String, Integer, WeatherCondition[]> {

	public interface IResponseAble {
		void onResponse(WeatherCondition[] wcs);
	}
	
	private IResponseAble mResponse;
	public static final int COUNT = 5;
	
	public UpdateWeatherTask(IResponseAble ra){
		super();
		mResponse = ra;
	}
	
	@Override
	protected WeatherCondition[] doInBackground(String... params) {
		WeatherCondition[] weathers = new WeatherCondition[COUNT];
		String city = params[0];
		for(int i=0;i<COUNT;i++){
			weathers[i] = WeatherFacade.getSinaWeather(city, i);
		}
		return weathers;
	}
	
	@Override
	protected void onPostExecute(WeatherCondition[] result) {
		mResponse.onResponse(result);
		super.onPostExecute(result);
	}

}

